package com.example.fresh_fruit.service.Impl;

import com.example.fresh_fruit.entity.Student;
import com.example.fresh_fruit.mapper.StudentMapper;
import com.example.fresh_fruit.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author :飞天の鱼
 * @date : 2022/8/4 14:49
 */
@SuppressWarnings({"all"})
@Service
//service层业务实现需要添加注解@Service，注入Mapper：
public class StudentServiceImpl implements StudentService {
    //@Autowired字段注入
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public boolean insertStudent(Student student) {
        return studentMapper.insert(student) > 0 ? true : false;
    }

    @Override
    public boolean deleteStudent(Integer id) {
        return studentMapper.delete(id) > 0 ? true : false;
    }

    @Override
    public boolean updeStudents(Student student) {
        return studentMapper.update(student) > 0 ? true : false;
    }

    @Override
    public Student findId(Integer id) {
        return studentMapper.findById(id);
    }

    @Override
    public List<Student> selectAll() {
        return studentMapper.selectAll();
    }

    @Override
    public boolean login(Student student) {
        return studentMapper.login(student);
    }
}
